﻿using AutoMapper;
using Common.Domain;
using Common.Infrastructure.Repository;
using Common.Services;
using MediatR;

namespace Business.ReadAPI.Application.Machinings
{
    public class AdditiveQueryRequestHandler : IRequestHandler<AdditiveQueryRequestModel, APIResult>
    {
        private IBaseRepository<Additive> baseRepository;
        private readonly IMapper mapper;
        public AdditiveQueryRequestHandler(IBaseRepository<Additive> baseRepository, IMapper mapper)
        {
            this.baseRepository = baseRepository;
            this.mapper = mapper;
        }
        public Task<APIResult> Handle(AdditiveQueryRequestModel request, CancellationToken cancellationToken)
        {
            APIResult result = new APIResult();
            result.Code = EnumCode.SearchSuccess;
            result.Msg = "查询成功";

            var list = baseRepository.GetAll().FirstOrDefault();
            result.Data = list;

            return Task.FromResult(result);
        }
    }
    public class AdditiveQueryRequestModel:IRequest<APIResult>
    {
    }
    public class AdditiveQueryResponseModel
    {
        public int Id { get; set; }
        public string ProductCode { get; set; }
        public string ProductionBatch { get; set; }
        public string Creator { get; set; }
        public DateTime CreateTime { get; set; }
    }
}
